﻿@using SH = EMoney.IStock.Client.Framework.StringHelper;

@{
    Layout = null;
    string latestMonth = string.Empty;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>题材领涨</title>
    <script type="text/javascript">if (top.window.location.href != window.location.href) { top.window.location.href = window.location.href }</script>
    <link rel="stylesheet" type="text/css" href="@ViewBag.PageCss" id="linkcss" />
</head>
<body>
<div class="tc_loading" id="tc_loading" style="display:none">数据加载中...</div>
<div class="mask" id="tc_mask" style="display:none"></div>
<div class="mr_cnt">
    <div class="mr_sp">
        <div id="top1box">
            <div class="bsboard fnt_tit" style="text-align:center;height:50px;" id="gczh1">
                <div style="float:left;text-align:center;width:84%;font-size:16px;padding-top:20px;">
                    @{if (ViewBag.RecentMonth != null && ViewBag.RecentMonth.Count > 0)
                        {
                            latestMonth = ViewBag.RecentMonth[0].key;
                            string showRecentMonth = ViewBag.RecentMonth[0].value;
                                
                            <div class="selbx" style="width:140px;">
                                <div class="slbtn sl spre"></div><dl>
                                    <dt><span>@showRecentMonth</span></dt>
                                    <dd id="ddDate" style="height:100px;">
                                        <div class="SELscroll scrollBox" scrollflag id="SELscroll0" style="height:100px;overflow:hidden;">
                                            <ul>@{
                            int forIndex = 0;
                            foreach (EMoney.IStock.Client.Models.KeyValue keyvalue in ViewBag.RecentMonth)
                            {
                                if (forIndex == 0)
                                {
                                                        <li class="cur" key="@keyvalue.key" svalue="@keyvalue.value">@keyvalue.value</li>
                                }
                                else
                                { 
                                                        <li key="@keyvalue.key" svalue="@keyvalue.value">@keyvalue.value</li>
                                }

                                forIndex++;
                            }
                                                }
                                            </ul>
                                        </div>
                                    </dd></dl><div class="slbtn sr"></div>
                            </div>
                        }
                        }
                    异动股票<span class="cr3" id="spanTotalNumber">--</span>只，筛选出<span class="cr3" id="spanListCount">--</span>只潜力股供您参考！
                </div>
                <a href="javascript:;" onclick="godetails();"><div class="cldetails1" style="float:right;margin-top:15px;margin-right:10px;"></div></a>
            </div>
            <div class="clr"></div>
        </div>
        <br />
        <div id="scrollBox1" class="scrollBox" scrollflag>
            <div class="bslist" id="bsList"></div>
        </div>
    </div>
</div>
    <div class="qatip" style="display:none"></div>
    <input type="hidden" id="hidLatestMonth" value="@latestMonth" />
    <input type="hidden" id="hidColor" value="@ViewBag.Color" />
</body>
</html>
<script src="http://static.emoney.cn/js/libs/jquery.min.1.8.3.js" type="text/javascript"></script>
<script src="@SH.GetStaticFile("IStockClientStatic/js/common.js")" type="text/javascript"></script>
<script src="@SH.GetStaticFile("IStockClientStatic/js/EMWEBUIscrollBar.js")" type="text/javascript"></script>
<script src="@SH.GetStaticFile("IStockClientStatic/js/istockfunc.js")" type="text/javascript"></script>
<script type="text/javascript">
    var www = "@Url.Content("~/")", selMonth = $("#hidLatestMonth").val(), allcode = "", hidColor = $("#hidColor").val();

    $(document).ready(function () {
        $(".detailEvent").followTips();

        $(".scrollBox").jscroll({ W: "8px", IW: "8px", CurrT: 0, Bar: { Pos: "up" }, Btn: { btn: false }, Fn: function () { } }).hover(function (e) {
            var thisbx = $(this), scrlbr = $(this).find(".jscroll-e");
            if (!scrlbr.hasClass("non")) {
                scrlbr.addClass("mon").stop(true, true, false).show();
            }
        }, function (e) {
            var thisbx = $(this), scrlbr = $(this).find(".jscroll-e");
            if (!scrlbr.hasClass("non")) {
                scrlbr.removeClass("mon");
                if (scrlbr.hasClass("vxdrag")) { } else {
                    //scrlbr.fadeOut("slow");
                }
            }
        });

        $(window).bind('load resize', '', function () {
            $(document).queue(function () {
                $(document).dequeue();
                var winH = $(window).height(), winW = $(window).width();
                //$("#scrollBox0").height(winH);
                $("#scrollBox1").height(winH - $("#top1box").height() - 20);

                ReSetScroll();
                //$(".scrollBox .jscroll-e").delay(800).fadeOut('slow');
            });
        });

        $("#scrollBox1").height($(window).height() - $("#top1box").height() - 20);

        $("#bsList").delegate('.more', 'click', '', function () {
            detailStocks = "";

            var $showMore = $(this).parents("table").next(".showMore")
            if ($(this).toggleClass("off").hasClass("off")) {
                $showMore.slideUp('fast', '', function () {
                    ReSetScroll();
                });
            } else {
                $showMore.slideDown('fast', '', function () {
                    ReSetScroll();
                });
            };
        }).delegate("ul li", "mouseenter", function () {
            $(this).find(".firstcol").addClass("firstcolhover");
            $(this).find(".secondcol").addClass("secondcolhover");
        }).delegate("ul li", "mouseleave", function () {
            $(this).find(".firstcol").removeClass("firstcolhover");
            $(this).find(".secondcol").removeClass("secondcolhover");
        }).delegate("ul li", "click", function () {
            if ($(this).attr("onshow") != undefined && $(this).attr("onshow") != "") {
                $("#bsList ul li").find(".firstcol").removeClass("firstcolsel");
                $("#bsList ul li").find(".secondcol").removeClass("secondcolsel");

                $(this).find(".firstcol").addClass("firstcolsel");
                $(this).find(".secondcol").addClass("secondcolsel");
                
                SyncGoods($(this).attr("onshow"),$(this).attr("trigger_date"));
            }
        }).delegate("ul li", "dblclick", function () {
            if ($(this).attr("onshow") != undefined && $(this).attr("onshow") != "") {
                GroupToKLine("题材领涨", $(this).attr("onshow"), allcode);
            }
        });

        getPool();

        bindCommonEvt();
    });

    function OnSkinChanged(skinName) {
        var cssHref = "";

        switch (skinName) {
            case "default":
                hidColor = skinName;
                cssHref = "@SH.GetStaticFile("IStockClientStatic/css/tcxg_tint.css")";
                break;
            case "black":
                hidColor = skinName;
                cssHref = "@SH.GetStaticFile("IStockClientStatic/css/tcxg.css")";
                break;
            default:
                break;
        }

        if (cssHref != "") {
            $("#linkcss").attr("href", cssHref);
        }
    }

    function bindCommonEvt() {
        var selBx = $(".selbx"), thisSelBx$;

        selBx.delegate("dt", "click", "", function () {
            var listBod = $(this).parent().find("dd")
            , TBheight = 100;
            listBod.show();
            
            if ($("ul", listBod).height() > TBheight) {
                $(".SELscroll", listBod).height(TBheight)
            } else {
                $(".SELscroll", listBod).css({ "height": "auto" });
            }
            ReSetScroll("#SELscroll0");
        })
        .mouseleave(function () { $("dd", this).hide(); })
        .delegate("li", "mouseover", "", function () { $(this).addClass("on").siblings().removeClass("on"); })
        .delegate("li", "click", "", function () {
            $(this).addClass("cur").siblings().removeClass("cur");

            $(this).parents("dl").find("dt>span").text($(this).text()).attr("data-value", $(this).attr("data-value"));

            var curItm = $(this), selBox = curItm.parents("dl"), seList = $("li", curItm.parent()), curIndex = seList.index(curItm), Itmsize = seList.length;

            if (curIndex == 0) {
                $(".sr").removeClass("snext");
                $(".sl").addClass("spre");
            } else if (curIndex == (Itmsize - 1)) {
                $(".sl").removeClass("spre");
                $(".sr").addClass("snext");
            } else {
                $(".sr").addClass("snext");
                $(".sl").addClass("spre");
            }

            try {//查询
                selMonth = $(this).attr("key");

                $("#ddDate").hide();

                getPool();
            } catch (e) { }

        }).delegate(".slbtn", "click", "", function () {
            var btnThis = $(this), thisSelBx = btnThis.siblings("dl"),
                slBtns = btnThis.parent().find(".slbtn"),
                Lbtn = slBtns.filter(".sl"),
                Rbtn = slBtns.filter(".sr"),
                seList = $("li", thisSelBx);
            if (!seList.hasClass("cur")) { seList.first().click(); }
            var curItm = $(".cur", thisSelBx);

            if (btnThis.hasClass("spre")) {
                if (!(curItm.next().length == 0)) {
                    curItm.next().click();
                }
            } else if (btnThis.hasClass("snext")) {
                if (!(curItm.prev().length == 0)) {
                    curItm.prev().click();
                }
            }

            var curItm = $(".cur", thisSelBx);
            var selBox = curItm.parents("dl"), seList = $("li", curItm.parent()), curIndex = seList.index(curItm), Itmsize = seList.length;

            if (curIndex == 0) {
                $(".sr").removeClass("snext");
                $(".sl").addClass("spre");
            } else if (curIndex == (Itmsize - 1)) {
                $(".sl").removeClass("spre");
                $(".sr").addClass("snext");
            } else {
                $(".sr").addClass("snext");
                $(".sl").addClass("spre");
            }
        });
    }

    function getPool() {
        //listStocks = "";
        var b = $("#begindate").val();
        var e = $("#seldate").val();

        $.ajax({
            type: "get",
            url: www + "tcxg/GetTclzPool",
            data: { m: selMonth },
            datatype: "text",
            success: function (data) {
                var totalNumber = 0;
                var listCount = 0;

                if (data != "") {
                    var arrData = data.split("^");
                    totalNumber = arrData[0];

                    var obj = eval('(' + arrData[1] + ')');

                    if (obj != null && obj.length > 0) {
                        var textHtml = "<ul>",arrS = [];

                        $.each(obj, function (i) {
                            if ($.inArray(obj[i].SecuCode, arrS) < 0) {
                                allcode += obj[i].SecuCode + ",";
                                arrS.push(obj[i].SecuCode);
                            }
                            
                            textHtml += "<li style='padding-right:10px;padding-left:10px;' onshow=\'" + obj[i].SecuCode + "\' trigger_date='" + parseDate(obj[i].DATE,"yyyyMMdd") + "' onshown=\"" + obj[i].SecuAbbr + "\">";
                            textHtml += "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
                            textHtml += "<tr><td align=\"middle\" valign=\"middle\" width=\"140\" class=\"firstcol\">";
                            textHtml += "<a href=\"javascript:void(0)\" hidefocus=\"true\"><span style='color:#fff'><b>" + obj[i].SecuAbbr + "</b><b>" + obj[i].SecuCode + "</b></span></a>";

                            if (obj[i].ListDetail != null && obj[i].ListDetail.length > 0) {
                                textHtml += "<a href=\"javascript:;\" hidefocus=\"true\" onshow=\"" + obj[i].SecuCode + "\" standard=\"" + obj[i].standard + "\" date=\"" + parseDate(obj[i].DATE) + "\" time=\"" + parseFullDate(obj[i].DATE) + "\" class=\"more off\"></a>";
                            }

                            textHtml += "</td>";
                            textHtml += "<td align=\"left\" valign=\"middle\" style='width:10px;'>";
                            textHtml += "<td align=\"left\" valign=\"middle\" class='secondcol'>";
                            textHtml += "<div class=\"tit fnt_num\">";
                            textHtml += "<div class=\"tcyxdate\">" + obj[i].DateTxt + "</div>";
                            //textHtml += "<div  class=\"tcyxgjz\"><a href=\"javascript:void(0)\" hidefocus=\"true\" class=\"adiscrib\" style=\"cursor: default; text-decoration: none; margin-left: 40px;\"><span>关键字：" + obj[i].Orgkeywords + "</span></a></div>";
                            textHtml += "<a href=\"javascript:;\" hidefocus=\"true\" style=\"cursor: default; text-decoration: none;\"><span class=\"adiscrib\">" + obj[i].REASON + "</span></a>";
                            textHtml += "</div><div class=\"cnt cnt_s\" style='color:#848484;padding:5px 15px 10px 20px;line-height:22px;'>" + obj[i].EVENT + "";
                                                        
                            textHtml += "</div>";

                            textHtml += "</td></tr></table>";

                            if (obj[i].ListDetail != null && obj[i].ListDetail.length > 0) {
                                textHtml += "<div class=\"showMore\"><div class=\"t\"><div class=\"r\"><div class=\"b\"><div class=\"l\"><div class=\"lt\"><div class=\"tr\"><div class=\"rb\"><div class=\"bl\"><div class=\"stab0\">";
                                textHtml += "<table id='DTable' id=\"scode_" + obj[i].SecuCode + parseDate(obj[i].DATE) + "\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
                                textHtml += "<thead><tr><th scope=\"col\" style='border-top:0px;'>日期</th><th scope=\"col\" style='border-top:0px;'>事件</th><th scope=\"col\" style='border-top:0px;'>累计收益</th></tr></thead>";

                                $.each(obj[i].ListDetail, function (j) {
                                    textHtml += "<tr onshow=\"" + obj[i].ListDetail[j].SecuCode + "\" style='font-size:12px;'>";
                                    //textHtml += "<td title=\"双击查看行情\" onclick=\"f_hqGetScodeDetail('" + obj[i].ListDetail[j].SecuCode + "',event)\" ondblclick=\"f_hqScodeDetail('" + obj[i].ListDetail[j].SecuCode + "','" + "scode_" + obj[i].SecuCode + parseDate(obj[i].DATE) + "',event)\" style=\"color:#EFCE5A\"><a href=\"javascript:void(0)\" hidefocus=\"true\" onclick=\"EM_FUNC_GETSTOCKCODE('" + obj[i].ListDetail[j].SecuCode + "')\" style=\"color:#EFCE5A\" class=\"astock\">" + obj[i].ListDetail[j].SecuAbbr + "</a></td>";
                                    textHtml += "<td style='text-align:center;font-size:12px;'>" + parseDate(obj[i].ListDetail[j].DATE) + "</td>";
                                    textHtml += "<td class=\"detailEvent\" style='text-align:center;font-size:12px;cursor:pointer;' event=\"" + obj[i].ListDetail[j].EVENT.replace(/"/g, "'") + "\">" + obj[i].ListDetail[j].REASON + "</td>";
                                    textHtml += "<td style=\"text-align:center;font-size:12px;\">&nbsp;" + obj[i].ListDetail[j].FlagText + "</td>";
                                    textHtml += "</tr>";
                                });

                                textHtml += "</table>";
                                textHtml += "</div></div></div></div></div></div></div></div></div></div>";
                            }

                            textHtml += "</li><br/>";
                        });

                        listCount = arrS.length;

                        textHtml += "</ul>";
                        
                        $("#bsList").html(textHtml);
                        $("#bsList").css("padding-top", "0");
                        
                        $(".detailEvent").followTips();
                        $("#bsList ul li:eq(0)").click();

                        if ($("#bsList .more").length == 1)
                        {
                            $("#bsList .more")[0].click();
                        }
                    }
                    else {
                        SyncGoods("0");
                        
                        $("#bsList").css("padding-top", $("#scrollBox1").height() / 2 - 10);
                        $("#bsList").html("<ul><li style='text-align:center;color:#828282;'>-- 暂无数据 --</li></ul>");
                    }
                }
                else {
                    $("#bsList").html("<ul><li style='text-align:center;color:#828282;'>-- 暂无数据 --</li></ul>");
                }

                $("#spanTotalNumber").html(totalNumber);
                $("#spanListCount").html(listCount);

                $("#tc_loading").hide();
                $("#tc_mask").hide();

                ReSetScroll();
            },
            beforeSend: function () {
                allcode = "";
                $("#tc_loading").show();
                $("#tc_mask").show();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
            }
        });
    }

    function godetails() {
        window.location.href = www + "tcxg/tclzdetails?color=" + hidColor;
    }
</script>